package 双指针;

public class 盛最多水的容器4 {
    //https://leetcode.cn/problems/container-with-most-water/
    public int maxArea(int[] height) {
        int left = 0, right = height.length - 1, max = 0;
        while(left < right) {
            int v = Math.min(height[left],height[right]) * (right - left);
            max = Math.max(max, v);
            if(height[left] < height[right]) {
                left++;
            }else {
                right--;
            }
        }
        return max;
    }
}
